#include<bits/stdc++.h>
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define rept(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) rept(i,0,n)
#define all(a) a.begin(),a.end()
#define sz(a) ((int)a.size())
#define il inline
#define db double
#define ld long double
#define re return
#define F first
#define S second
#define int long long
using namespace std;
template<typename T>void Mx(T &a,T b){if(a<b)a=b;}
template<typename T>void Mi(T &a,T b){if(a>b)a=b;}
const int MOD=998244353;
const int INF=1000000000000000000;
void FILEIO(string s){
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
}
const int N=100005;
int n,m,l,mxv;
bool chk(int ds,int sv,int a){
    re (sv*sv+2*a*ds)>mxv*mxv;
}
int sd[N],sv[N],a[N];
int pos[N];
pii getseg(int i){
    int nxt=lower_bound(pos,pos+m,sd[i])-pos;
    if(nxt==m)re {-1,-1};
    int ca=a[i];
    if(ca==0){
        if(sv[i]>mxv)re {nxt,m-1};
        re {-1,-1};
    }
    if(ca>0){
        int l=nxt,r=m;
        while(l<r){
            int mid=(l+r)>>1;
            if(chk(pos[mid]-sd[i],sv[i],ca))r=mid;
            else l=mid+1;
        }
        if(l==m)re {-1,-1};
        re {l,m-1};
    }
    if(ca<0){
        int l=nxt,r=m;
        while(l<r){
            int mid=(l+r)>>1;
            if(!chk(pos[mid]-sd[i],sv[i],ca))r=mid;
            else l=mid+1;
        }
        if(l==nxt)re {-1,-1};
        re {nxt,l-1};
    }
}
void run(){
    cin>>n>>m>>l>>mxv;
    rep(i,n)cin>>sd[i]>>sv[i]>>a[i];
    rep(i,m)cin>>pos[i];
    pos[m]=l+1;
    vector<pii>pp;
    rep(i,n){
        pii cur=getseg(i);
        if(cur.F<0)continue;
        pp.pb(cur);
    }
    sort(all(pp));
    int las=-1,rm=INF,ans=0;
    for(pii p:pp){
        if(p.F>rm)las=rm,rm=INF,ans++;
        if(p.F<=las)continue;
        Mi(rm,p.S);
    }
    ans++;
    cout<<sz(pp)<<" "<<m-ans<<"\n";
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    FILEIO("detect");
    int T=1;
    cin>>T;
    while(T--)run();
    re 0;
}